package jfox.platform.datadict.dao;

import java.util.Collections;
import java.util.List;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;

import jfox.platform.datadict.entity.DictCategory;
import jfox.platform.infrastructure.SuperDAO;

/**
 * @author <a href="mailto:yang_y@sysnet.com.cn">Young Yang</a>
 */
@NamedNativeQueries(
        {
        @NamedNativeQuery(
                name = DictCategoryDAOBean.GET_CATEGORY_BY_ID,
                query = "SELECT * FROM T_DICT_CATEGORY WHERE ID=$ID",
                resultClass = DictCategory.class),
        @NamedNativeQuery(
                name = DictCategoryDAOBean.GET_ALL_CATEGORY,
                query = "SELECT * FROM T_DICT_CATEGORY",
                resultClass = DictCategory.class)
                }
)
@Stateless
@Local
public class DictCategoryDAOBean extends SuperDAO implements DictCategoryDAO {

    public final static String GET_CATEGORY_BY_ID = "getCategory";
    public final static String GET_ALL_CATEGORY = "getAllCategory";

    public DictCategory getCategory(long id) {
        return (DictCategory)getEntityObjectByColumn(GET_CATEGORY_BY_ID, "ID", id);
    }

    public List<DictCategory> getAllCategory() {
        return (List<DictCategory>)processNamedNativeQuery(GET_ALL_CATEGORY, Collections.EMPTY_MAP);
    }
}
